goog.provide('dkpoints.nav.NYIHandler');

goog.require('dkpoints.errors.templates');


/**
 * @fileoverview
 * Equivalent of HTTP 501 error - Not Implemented.  Denotes that the path the
 * user navigated to is in the URL mappings, but a handler has not yet been
 * implemented.
 */



/**
 * Tells the user that this path has not yet been implemented.
 * @param {dkpoints.ServiceProvider} sp The ServiceProvider object with all the
 *    cool dependencies baked in.
 * @constructor
 * @implements {dkpoints.nav.Handler}
 */
dkpoints.nav.NYIHandler = function(sp) {
  /**
   * @type {!Element}
   * @private
   */
  this.bodyContent_ = sp.getBodyContent();
};


/**
 * The auth level required for this module (no authorization required)
 * @type {dkpoints.auth.AuthState}
 * @const
 */
dkpoints.nav.NYIHandler.requiredAuth = dkpoints.auth.AuthState.NO_AUTH;


/**
 * Posts a message on the page that tells the user that the page they navigated
 * to has not yet been implemented.
 * @param {dkpoints.nav.Path} path The path for this request.
 */
dkpoints.nav.NYIHandler.prototype.handle = function(path) {
  this.bodyContent_.innerHTML = dkpoints.errors.templates.notImplemented();
};


/**
 * When the handler instance is already active, transition will be called on
 * new navigations instead of handle to allow the handler to more easily
 * transition set up the new state of the active driver instead of rebuilding
 * it from scratch.
 * @param {dkpoints.nav.Path} path An object with request-specific parameters.
 * @param {function()} onCancel Callback to be invoked if user decides
 *    not to navigate away from what they're doing.
 */
dkpoints.nav.NYIHandler.prototype.transition = function(path, onCancel) {
  this.handle(path);
};


/**
 * Save state and clear the user-interface so the next handler can use the
 * screen.
 * @param {function(boolean)} onExit Callback once exit is either
 *    complete or cancelled by the user.  Passing true to the callback means
 *    that the handler has relinquished control of thep age; false means
 *    the user opted not to navigate away.
 */
dkpoints.nav.NYIHandler.prototype.exit = function(onExit) {
  this.bodyContent_.innerHTML = '';
  onExit(true);
};
